<!--
 * @Description: 
 * @Author: gphper
 * @Date: 2021-09-26 19:47:26
-->
{{define "head"}}

{{end}}


{{define "body"}}
<div class="container" style="margin-top: 10px;">
<div class="row">
    <div class="col-sm-8">
        <div role="toolbar" aria-label="Toolbar with button groups">
            <div class="input-group">
                  <div class="input-group-prepend">
                    <div class="input-group-text" id="btnGroupAddon">ZSET:</div>
                  </div>
                  <input type="text" name="key" class="form-control" value="{{.key}}" disabled>
            </div>
        </div>
    </div>

    <div class="col-sm-4" data-toggle="modal" data-target="#exampleModal">
        <div role="toolbar" aria-label="Toolbar with button groups">
            <div class="input-group">
                  <div class="input-group-prepend">
                    <div class="input-group-text" id="btnGroupAddon">TTL:</div>
                  </div>
                  <input type="text" name="key" class="form-control" value="{{.time}}" disabled>
            </div>
        </div>
    </div>

    <div class="col-sm-12" style="margin-top: 10px;">
      <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#addZsetModal">
        新增元素
      </button>
    </div>
    <div class="col-sm-12" style="overflow-y: auto;height: 500px;margin-top: 10px;">
      <table class="table">
        <thead class="thead-light">
          <tr>
            <th scope="col">序号</th>
            <th scope="col">值</th>
            <th scope="col">分数</th>
            <th scope="col">操作</th>
          </tr>
        </thead>
        <tbody>
          {{range $i,$v := .zvalue}}
          <tr>
            <td>{{$i}}</td>
            <td>{{$v.Member}}</td>
            <td>{{$v.Score}}</td>
            <td>
              <form action="/zset/del" method="post" class="ajaxForm" autocomplete="off">
                <input type="hidden" name="key" value="{{$.key}}">
                <input type="hidden" name="member" value="{{$v.Member}}">
                <button type="submit" class="btn btn-sm btn-danger">删除</button>
              </form>
            </td>
          </tr>
          {{end}}
          
        </tbody>
      </table>
    </div>
</div>
</div>


<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">设置键的TTL</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <form action="/string/ttl" method="post" class="ajaxForm" autocomplete="off">
        <div class="modal-body">
            <div class="form-group">
              <label>新的TTL(-1 表示永不过期)</label>
              <input type="text" name="ttl" class="form-control" required>
              <input type="hidden" name="key" value="{{.key}}">
            </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
          <button type="submit" class="btn btn-primary">保存</button>
        </div>
      </form>
      </div>
    </div>
  </div>


<!-- Modal -->
<div class="modal fade" id="addZsetModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">添加元素</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <form action="/zset/add" method="post" class="ajaxForm" autocomplete="off">
      <div class="modal-body">
          <input type="hidden" name="key" value="{{.key}}">
          <div class="form-group">
            <label>字段值</label>
            <input type="text" name="value" class="form-control" required>
          </div>
          <div class="form-group">
            <label>分数值</label>
            <input type="text" name="score" class="form-control" required>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
        <button type="submit" class="btn btn-primary">保存</button>
      </div>
    </form>
    </div>
  </div>
</div>

{{end}}


{{define "script"}}

{{end}}